﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.Model;

namespace iLangl.Customer.Managers
{
	public class SynchronizationManager
	{
		#region Singelton Pattern


		private static SynchronizationManager instance;
		private static object mutex = new object();
		/// <summary>
		/// The instance of the SynchronizationManager.
		/// </summary>
		public static SynchronizationManager Instance
		{
			get
			{
				if (instance == null)
				{
					lock (mutex)
					{
						if (instance == null)
						{
							instance = new SynchronizationManager();

						}
					}
				}
				return instance;
			}
		}
		#endregion

		public void SyncData(SyncedOneWayData result)
		{
			foreach (ICompany company in result.Companies)
			{
				CompanyManager.Instance.UpdateCompanyInfo((CustomerCompany)company);
			}

			foreach (IProject project in result.Projects)
			{
				ProjectManager.Instance.Update((CustomerProject)project);
			}
		}
	}
}
